<?php

/**
 * This is the model class for table "usuario".
 *
 * The followings are the available columns in table 'usuario':
 * @property integer $Id_usuario
 * @property string $Nome_usuario
 * @property string $Login_usuario
 * @property string $Senha_usuario
 * @property string $CPF_usuario
 */
class Usuario extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Usuario the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'usuario';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('Nome_usuario, Login_usuario, Senha_usuario, CPF_usuario', 'required'),
			array('Nome_usuario, Login_usuario, Senha_usuario', 'length', 'max'=>255),
			array('CPF_usuario', 'length', 'max'=>11),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('Id_usuario, Nome_usuario, Login_usuario, Senha_usuario, CPF_usuario', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'Id_usuario' => 'Id Usuario',
			'Nome_usuario' => 'Nome Usuario',
			'Login_usuario' => 'Login Usuario',
			'Senha_usuario' => 'Senha Usuario',
			'CPF_usuario' => 'Cpf Usuario',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('Id_usuario',$this->Id_usuario);
		$criteria->compare('Nome_usuario',$this->Nome_usuario,true);
		$criteria->compare('Login_usuario',$this->Login_usuario,true);
		$criteria->compare('Senha_usuario',$this->Senha_usuario,true);
		$criteria->compare('CPF_usuario',$this->CPF_usuario,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}